package com.ljkj.cordial.chat.activity;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.widget.TextView;

import com.lanjiu.lib.imclient.ims.IMSContacts;
import com.ljkj.cordial.chat.R;
import com.ljkj.cordial.chat.base.BaseActivity;
import com.ljkj.cordial.chat.bean.Canstants;
import com.ljkj.cordial.chat.dao.notify.BusinessLeaveTable;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 好友申请被拒绝，加群申请被拒绝
 */
public class RefuseFriendActivity extends BaseActivity {


    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_hint)
    TextView tvHint;
    @BindView(R.id.tv_refuse_reason)
    TextView tvRefuseReason;
    private int chatType;
    private BusinessLeaveTable table;

    @Override
    public int getContentLayoutId() {
        return R.layout.activity_refuse_friend;
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
        table = (BusinessLeaveTable) getIntent().getSerializableExtra(Canstants.KEY_LEAVE_INFO);
        if (table != null) {
            switch (table.getTargetStatus()) {
                //消息类型为7，INVITE_REFUSE_TOURISTS,游客用户拒绝群主邀请的消息
                case IMSContacts.MsgContentType.INVITE_REFUSE_TOURISTS:
                    getToolbar().setTitle(table.getTargetUserName());
                    tvHint.setText("拒绝了你的邀请");
                    break;
                //消息类型为8，INVITE_REFUSE_REGISTERED,注册用户拒绝群主邀请的消息
                case IMSContacts.MsgContentType.INVITE_REFUSE_REGISTERED:
                    getToolbar().setTitle(table.getTargetUserName());
                    tvHint.setText("拒绝了你的邀请");
                    break;
                //消息类型为11，APPLY_REFUSE_TOURISTS,游客群主拒绝申请入群的消息
                case IMSContacts.MsgContentType.APPLY_REFUSE_TOURISTS:
                    getToolbar().setTitle(table.getTargetGroupName());
                    tvHint.setText("拒绝了你的入群申请");
                    break;
                //消息类型为12，APPLY_REFUSE_REGISTERED,注册群主拒绝申请入群的消息
                case IMSContacts.MsgContentType.APPLY_REFUSE_REGISTERED:
                    getToolbar().setTitle(table.getTargetGroupName());
                    tvHint.setText("拒绝了你的入群申请");
                    break;
                //消息类型15，游客用户好友申请拒绝
                case IMSContacts.MsgContentType.APPLY_REFUSE_FRIEND_TOURISTS:
                    getToolbar().setTitle(table.getTargetUserName());
                    tvHint.setText("拒绝了你的好友申请");
                    break;
                //消息类型16，注册用户好友申请拒绝
                case IMSContacts.MsgContentType.APPLY_REFUSE_FRIEND_REGISTERED:
                    getToolbar().setTitle(table.getTargetUserName());
                    tvHint.setText("拒绝了你的好友申请");
                    break;
            }
            if (!TextUtils.isEmpty(table.getTargetUserName()))
                tvName.setText(table.getTargetUserName());
            tvRefuseReason.setText(table.getTargetLeave());
        }
    }

    public static void jumpTo(Context activity, BusinessLeaveTable table) {
        Intent intent = new Intent(activity, RefuseFriendActivity.class);
        intent.putExtra(Canstants.KEY_LEAVE_INFO, table);
        activity.startActivity(intent);
    }

}
